package it.low.game.core.element;

import it.low.game.core.element.activity.Posizionable;
import it.low.game.core.location.MapPoint;
import it.low.game.core.message.ElementState;

import java.awt.geom.RectangularShape;

public abstract class Element implements Posizionable {

	protected State state = new State();
	protected int mapAreaWidth = 0;
	protected int mapAreaHeight = 0;
			
	public abstract long getElementId();
	
	public void setMapPosition(MapPoint mapPosition){
		state.setMapPosition(mapPosition);		
	}
	
	public MapPoint getMapPosition(){
		return this.state.getMapPosition();
	}
	
	public boolean isClose(Element element){
		int maxDist = this.mapAreaWidth + element.mapAreaWidth;
		if(this.getMapPosition().isNear(element.getMapPosition(), maxDist)){
			return true;
		}else{
			return false;
		}		
	}
	
	public ElementState getElementState(){
		return new ElementState(getElementId(),state);
	}
	
	public abstract RectangularShape getMapArea();
		
	public abstract String getElementName();
	
}
